import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class TheArrayTest {

    protected TheArray solution;

    @Before
    public void setUp() {
        solution = new TheArray();
    }

    @Test
    public void testCase0() {
        int n = 3;
        int d = 5;
        int first = 2;
        int last = 4;

        int expected = 7;
        int actual = solution.find(n, d, first, last);

        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testCase1() {
        int n = 10;
        int d = 100;
        int first = 999;
        int last = 100;

        int expected = 999;
        int actual = solution.find(n, d, first, last);

        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testCase2() {
        int n = 1000000;
        int d = 0;
        int first = 474;
        int last = 474;

        int expected = 474;
        int actual = solution.find(n, d, first, last);

        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testCase3() {
        int n = 97;
        int d = 53;
        int first = -92;
        int last = 441;

        int expected = 2717;
        int actual = solution.find(n, d, first, last);

        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testCase4() {
        int n = 99;
        int d = 3;
        int first = -743;
        int last = -619;

        int expected = -535;
        int actual = solution.find(n, d, first, last);

        Assert.assertEquals(expected, actual);
    }

}
